package thread;

/**
 * 线程的优先级
 * 1-10表示，1最低，10最高，5是默认
 *
 * 当线程调用start方法被纳入到线程调度器中统一管理后，线程只能被动分配时间片，不能主动索取
 *
 */
public class PriorityDemo {
    public static void main(String[] args) {
        Thread min = new Thread(){
            @Override
            public void run() {
                for (int i = 0; i < 10000; i++) {
                    System.out.println("min");
                };
            }
        };
        Thread max = new Thread(){
            @Override
            public void run() {
                for (int i = 0; i < 10000; i++) {
                    System.out.println("max");
                };
            }
        };
        Thread norm = new Thread(){
            @Override
            public void run() {
                for (int i = 0; i < 10000; i++) {
                    System.out.println("nor");
                };
            }
        };
        min.setPriority(Thread.MIN_PRIORITY);
        max.setPriority(Thread.MAX_PRIORITY);
        min.start();
        max.start();
        norm.start();
    }
}
